package com.cee.quartz.job;

import com.cee.quartz.job.base.BaseQuartzJob;
import com.cee.sch.job.dto.ScheduleJobLogDTO;
import com.cee.util.JsonUtil;
import org.quartz.JobDataMap;
import org.quartz.JobDetail;
import org.quartz.SchedulerException;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Component;

@Component
public class QuartzJob extends BaseQuartzJob {

    private static final Logger logger = LoggerFactory.getLogger(QuartzJob.class);

    @Override
    protected void executeJob(JobDetail jobDetail, ScheduleJobLogDTO jobLog) throws SchedulerException {
        // 解析创建该定时任务时设置的数据
        JobDataMap dataMap = jobDetail.getJobDataMap();
        logger.info("dataMap: {}", JsonUtil.format(dataMap));

        jobLog.setRecFail(0L);
        jobLog.setRecSuccess(1L);
        jobLog.setRecTotal(1L);
    }

    @Override
    protected JobType getJobType() {
        return JobType.LOCAL;
    }
}